package com.suke.czx.modules.task.entity;

import cn.hutool.core.date.DatePattern;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.suke.czx.common.validate.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 应用模块名称: 任务
 * 代码描述: 任务实体
 * copyright: AUZAR ALL RIGHTS RESERVED
 * company: AUZAR
 *
 * @author: 颜米晨
 * @date: 2021/09/11 16:55
 */
@Data
@ApiModel(value = "任务管理")
@EqualsAndHashCode(callSuper = true)
public class Task extends Model<Task> {

    @ApiModelProperty(value = "任务id")
    @TableId(value = "task_id", type = IdType.AUTO)
    @NotNull(groups = {TaskUpdateGroup.class}, message = "任务编码不能为空")
    public Long taskId;

    @ApiModelProperty(value = "任务名称")
    @NotBlank(groups = {TaskSaveGroup.class, TaskUpdateGroup.class}, message = "任务名称不能为空")
    public String taskName;

    @ApiModelProperty(value = "任务级别(1 一级任务 2 二级任务 3 三级任务)")
    @NotNull(groups = {TaskSaveGroup.class, TaskUpdateGroup.class}, message = "任务级别不能为空")
    @EnumValue(groups = {TaskSaveGroup.class, TaskUpdateGroup.class}, intValues = {1, 2, 3}, message = "任务级别只能是1,2,3")
    private Integer taskLevel;

    @ApiModelProperty(value = "任务目标")
    public String taskTarget;

    @ApiModelProperty(value = "任务kpi")
    public String taskKpi;

    @ApiModelProperty(value = "开始日期")
    @NotNull(groups = {TaskSaveGroup.class, TaskUpdateGroup.class}, message = "开始日期不能为空")
    @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    public Date beginDate;

    @ApiModelProperty(value = "计划交付日期")
    @NotNull(groups = {TaskSaveGroup.class, TaskUpdateGroup.class}, message = "计划交付日期不能为空")
    @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    public Date planCompleteDate;

    @ApiModelProperty(value = "实际完成日期")
    @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    public Date completeDate;

    @ApiModelProperty(value = "员工编码")
    @NotNull(groups = {TaskSaveGroup.class, TaskUpdateGroup.class}, message = "员工编码不能为空")
    public String userIds;

    @TableField(exist = false)
    @ApiModelProperty(value = "员工姓名")
    public String userNames;

    @ApiModelProperty(value = "任务类型(1 项目任务 2 其他任务)")
    @NotNull(groups = {TaskSaveGroup.class, TaskUpdateGroup.class}, message = "任务类型不能为空")
    @EnumValue(groups = {TaskSaveGroup.class, TaskUpdateGroup.class}, intValues = {1, 2}, message = "任务级别只能是1,2")
    public Integer taskType;

    @TableField(exist = false)
    @ApiModelProperty(value = "任务类型分类名称")
    public String taskTypeName;

    @ApiModelProperty(value = "关联项目编码")
    public Long projectId;

    @ApiModelProperty(value = "三级任务状态(1 等待中 2进行中 3 完成 4 暂停),用于三级任务员工自己变更任务状态")
    @EnumValue(groups = {TaskSaveGroup.class, TaskUpdateGroup.class}, intValues = {1, 2, 3, 4}, message = "三级任务状态只能是1,2,3,4")
    public Integer status;

    @TableField(exist = false)
    @ApiModelProperty(value = "三级任务状态名称")
    public String statusName;

    @ApiModelProperty(value = "完成质量(1 合格 2 不合格 3 良 4 优)")
    @EnumValue(groups = {TaskSaveGroup.class, TaskUpdateGroup.class}, intValues = {1, 2, 3, 4}, message = "完成质量只能是1,2,3,4")
    public Integer completeQuality;

    @TableField(exist = false)
    @ApiModelProperty(value = "完成质量名称")
    public String completeQualityName;

    @ApiModelProperty(value = "任务紧急程度(1 紧急 2 加急 3 普通)")
    @NotNull(groups = {TaskSaveGroup.class, TaskUpdateGroup.class}, message = "任务等级不能为空")
    @EnumValue(groups = {TaskSaveGroup.class, TaskUpdateGroup.class}, intValues = {1, 2, 3}, message = "完成质量只能是1,2,3")
    public Integer level;

    @TableField(exist = false)
    @ApiModelProperty(value = "任务紧急程度名称")
    public String levelName;

    @ApiModelProperty(value = "二级任务进度(1 等待中 2进行中 3 完成 4 暂停)")
    @EnumValue(groups = {TaskSaveGroup.class, TaskUpdateGroup.class}, intValues = {1, 2, 3, 4}, message = "二级任务进度只能是1,2,3,4")
    public Integer progress;

    @TableField(exist = false)
    @ApiModelProperty(value = "二级任务进度名称")
    public String progressName;

    @ApiModelProperty(value = "二级任务绩效分数")
    public BigDecimal performanceCategory;

    @ApiModelProperty(value = "一级任务权重")
    public BigDecimal proportion;

    @ApiModelProperty(value = "父任务编码")
    public Long parentId;

    @ApiModelProperty(value = "文件ids")
    public String fileIds;

    @ApiModelProperty(value = "备注")
    public String note;

    @ApiModelProperty(value = "删除标记  0：删除   1：正常")
    public Integer del;

    @ApiModelProperty(value = "创建者id")
    public Long creator;

    @ApiModelProperty(value = "创建时间")
    public Date createTime;

    @ApiModelProperty(value = "更新者id")
    public Long updater;

    @ApiModelProperty(value = "更新时间")
    public Date updateTime;

    @TableField(exist = false)
    @ApiModelProperty(value = "子任务数据集")
    public List<Task> children;

}
